package com.qiniu.githubdata.utils;

import com.qiniu.githubdata.entity.Contribution;

/**
 * @Author: mayixiang
 * @Date: 2024-11-06 11:07
 * @Description:
 */
public class ContributionUtil {
    public static double calculateContributionScore(Contribution contribution) {
        int totalContributions = contribution.getTotalContributions();
        int prCount = contribution.getPrCount();
        int issueCount = contribution.getIssueCount();
        int lineChanges = contribution.getLineChanges();
        if (totalContributions == 0) {
            return 0.0;
        }
        double contributionWeight = 0.5;
        double prWeight = 0.3;
        double issueWeight = 0.1;
        double lineWeight = 0.1;
        return ((double)totalContributions * contributionWeight +
                (double)   prCount * prWeight +
                (double) issueCount * issueWeight +
                (double )lineChanges * lineWeight);
//        return 0.0;
    }
}
